home *** CD-ROM | disk | FTP | other *** search
- title Drag'n'Play
- rem VDS example script; author: Julian Moss
- DIALOG CREATE,Drag'n'Play,100,100,256,112,DRAGDROP
- DIALOG ADD,TEXT,T1,10,10,160,80
- DIALOG ADD,CHECK,CB,10,180,,,AutoPlay,1
- DIALOG ADD,BUTTON,Play,32,180
- DIALOG ADD,BUTTON,Stop,62,180
- DIALOG ADD,STATUS,SP,Drag files to the window to play them
- DIALOG SHOW
- dialog disable,Play
- dialog disable,Stop
- if %2
- %F = %2
- goto file
- end
- :loop
- wait event
- goto @event()
- :close
- goto closemedia
- :dragdrop
- rem this event is generated when file(s) are dropped
- gosub closemedia
- list create,1
- rem get the list of files
- list dropfiles,1
- rem use the first filename only
- %F = @next(1)
- list close,1
- :file
- rem accept only WAV, MID, RMI or AVI files
- if @equal(@ext(%F),WAV)@equal(@ext(%F),MID)@equal(@ext(%F),RMI)@equal(@ext(%F),AVI)
- dialog clear,SP
- %X = @name(%F).@ext(%F)@CR()
- %R = @mci(open @shortname(%F) alias media wait)
- if @ok()
- %R = @mci(set media time format ms))
- if @equal(@ext(%F),WAV)
- %R = @mci(status media channels)
- if @equal(%R,1)
- %X = %XMono@CR()
- else
- %X = %XStereo@CR()
- end
- %R = @mci(status media bitspersample)
- %X = %X%R bits per sample@CR()
- %R = @mci(status media samplespersec)
- %X = %X@fdiv(%R,1000)kHz sampling rate@CR()
- end
- %T = @mci(status media length)
- if @greater(60000,%T)
- %R = @format(@fdiv(%T,1000),4.1) seconds
- else
- %R = @format(@fdiv(%T,60000),4.1) minutes
- end
- %X = %XLength %R
- dialog set,T1,%X
- if @equal(@ext(%F),AVI)
- window position,#AVIWnd,100,360
- %R = @mci(window media state show wait)
- end
- if @dlgtext(CB)
- goto playmedia
- else
- dialog enable,Play
- end
- end
- end
- goto loop
- :playbutton
- goto playmedia
- :stopbutton
- %R = @mci(stop media)
- dialog clear,SP
- dialog enable,Play
- dialog disable,Stop
- goto loop
- :playmedia
- dialog enable,Stop
- dialog disable,Play
- %R = @mci(seek media to start)
- dialog set,SP,Playing: 0%
- %R = @mci(play media)
- :ploop
- %P = %R
- wait 2,event
- goto @event()
- :timer
- %R = @mci(status media position)
- dialog set,SP,Playing: @div(@prod(%R,100),%T)%
- if @not(@equal(%R,%P))
- goto ploop
- end
- dialog clear,SP
- else
- warn MCI error: %R
- end
- dialog enable,Play
- dialog disable,Stop
- goto loop
- :closemedia
- %R = @mci(close media)
- exit
-